USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[DeleteAllLogDataByLogId]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.DeleteAllLogDataByLogId
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 08/29/08
-- Description:	Deletes all logged table data by LogId
-- =============================================
CREATE PROCEDURE DeleteAllLogDataByLogId

@LogId int

AS
BEGIN

	DELETE FROM Assists WHERE LogId = @LogId
	DELETE FROM CaptureBlocks WHERE LogId = @LogId
	DELETE FROM CaptureList WHERE CaptureId IN (SELECT CaptureId FROM Captures WHERE LogId = @LogId)
	DELETE FROM Captures WHERE LogId = @LogId
	DELETE FROM ChatLog WHERE LogId = @LogId
	DELETE FROM Destructions WHERE LogId = @LogId
	DELETE FROM Dominations WHERE LogId = @LogId
	DELETE FROM Engineering WHERE LogId = @LogId
	DELETE FROM Flag WHERE LogId = @LogId
	DELETE FROM Kills WHERE LogId = @LogId
	DELETE FROM LogFiles WHERE LogId = @LogId
	DELETE FROM MatchPlayerList WHERE MatchId IN (SELECT MatchId FROM Matches WHERE LogId = @LogId)
	DELETE FROM Matches WHERE LogId = @LogId
	DELETE FROM MedicCharge WHERE LogId = @LogId
	DELETE FROM Revenges WHERE LogId = @LogId
	DELETE FROM Rounds WHERE LogId = @LogId
	DELETE FROM Suicides WHERE LogId = @LogId


END
GO
